package com.huanxing.cloud.auth.controller;

import com.huanxing.cloud.common.core.entity.R;
import com.huanxing.cloud.common.security.annotation.HxInner;
import com.huanxing.cloud.common.security.utils.SecurityUtils;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/** @Description TODO @Author lijx @Date 2022/1/25 15:50 @Version v1.0 */
@RestController
@RequestMapping("token")
@AllArgsConstructor
public class TestController {

  @GetMapping("/auth")
  @HxInner
  public R test(String token) {
    return R.success(SecurityUtils.getUser());
  }

  @PreAuthorize("hasRole('ROLE_ADMIN')")
  @GetMapping
  public R testAuth() {
    return R.success();
  }
}
